package com.ly.web.controller.erp;

import com.ly.common.annotation.Log;
import com.ly.common.core.domain.AjaxResult;
import com.ly.common.enums.BusinessType;
import com.ly.heart.domain.SysSetupEntity;
import com.ly.heart.domain.dto.SysSetupDto;
import com.ly.heart.service.ISysSetupService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.web.bind.annotation.*;

import javax.annotation.Resource;

/**
 * <p>
 * 系统设置 前端控制器
 * </p>
 *
 * @author WuZH
 * @since 2024-10-02
 */
@Api ( value = "SysSetup", tags = "系统设置" )
@RestController
@RequestMapping ( "/heart/SysSetup" )
public class SysSetupController {

    @Resource
    private ISysSetupService iSysSetupService;

    @PreAuthorize ( "@ss.hasPermi('heart:SysSetup:list')" )
    @GetMapping ( "list" )
    public AjaxResult list ( SysSetupEntity sysSetupEntity ) {
        return iSysSetupService.list ( sysSetupEntity );
    }

    @PreAuthorize ( "@ss.hasPermi('heart:SysSetup:query')" )
    @GetMapping ( "single" )
    @ApiOperation ( "获取系统设置详情" )
    public AjaxResult getInfo ( SysSetupEntity sysSetupEntity ) {
        return AjaxResult.success ( iSysSetupService.querySingle ( sysSetupEntity ) );
    }

    @PreAuthorize ( "@ss.hasPermi('heart:SysSetup:add')" )
    @Log ( title = "系统设置", businessType = BusinessType.INSERT )
    @PostMapping
    @ApiOperation ( "新增系统设置" )
    public AjaxResult add ( @RequestBody SysSetupDto sysSetupDto ) {
        return iSysSetupService.saveSingle ( sysSetupDto );
    }

}
